home *** CD-ROM | disk | FTP | other *** search
/ Champak 128 / Vol 128 (Damaged).iso / games / fire_it_.swf / scripts / __Packages / Bounds.as < prev   
Encoding:
Text File  |  2011-03-26  |  4.3 KB  |  174 lines

  1. class Bounds
  2. {
  3.    static var ┬º#29┬º = 1;
  4.    function Bounds()
  5.    {
  6.    }
  7.    static function getXMin()
  8.    {
  9.       if(Bounds.xmin == undefined)
  10.       {
  11.          Bounds.xmin = Math.round(_root.bounds.getBounds(_root).xMin);
  12.       }
  13.       return Bounds.xmin;
  14.    }
  15.    static function getXMax()
  16.    {
  17.       if(Bounds.xmax == undefined)
  18.       {
  19.          Bounds.xmax = Math.round(_root.bounds.getBounds(_root).xMax);
  20.       }
  21.       return Bounds.xmax;
  22.    }
  23.    static function getYMin()
  24.    {
  25.       if(Bounds.ymin == undefined)
  26.       {
  27.          Bounds.ymin = Math.round(_root.bounds.getBounds(_root).yMin);
  28.       }
  29.       return Bounds.ymin;
  30.    }
  31.    static function getYMax()
  32.    {
  33.       if(Bounds.ymax == undefined)
  34.       {
  35.          Bounds.ymax = Math.round(_root.bounds.getBounds(_root).yMax);
  36.       }
  37.       return Bounds.ymax;
  38.    }
  39.    static function toString()
  40.    {
  41.       var _loc2_ = _root.bounds.getBounds(_root);
  42.       return "xMin=" + Math.round(_loc2_.xMin) + ", xMax=" + Math.round(_loc2_.xMax) + ", yMin=" + Math.round(_loc2_.yMin) + ", yMax=" + Math.round(_loc2_.yMax);
  43.    }
  44.    static function ┬º#469┬º()
  45.    {
  46.       var _loc4_ = new Object();
  47.       _loc4_.onMouseDown = function()
  48.       {
  49.          var _loc3_ = _root._xmouse;
  50.          var _loc2_ = _root._ymouse;
  51.          eval("#0").log("mouse x=" + _loc3_ + ", y=" + _loc2_ + ", in bounds: " + Bounds["#366"](_loc3_,_loc2_) + ", x bound: " + Bounds["#118"](_loc3_,_loc2_) + ", y bound: " + Bounds["#119"](_loc3_,_loc2_));
  52.       };
  53.       Mouse.addListener(_loc4_);
  54.    }
  55.    static function ┬º#366┬º(x, y)
  56.    {
  57.       return _root.bounds.hitTest(x,y,true);
  58.    }
  59.    static function ┬º#177┬º(mc)
  60.    {
  61.       var _loc3_ = mc.getBounds(_root).xMin;
  62.       var _loc2_ = mc.getBounds(_root).yMin;
  63.       if(!_root.bounds.hitTest(_loc3_,_loc2_,true))
  64.       {
  65.          return false;
  66.       }
  67.       _loc3_ = mc.getBounds(_root).xMax;
  68.       _loc2_ = mc.getBounds(_root).yMax;
  69.       if(!_root.bounds.hitTest(_loc3_,_loc2_,true))
  70.       {
  71.          return false;
  72.       }
  73.       return true;
  74.    }
  75.    static function ┬º#216┬º(mc)
  76.    {
  77.       if(Bounds["#177"](mc))
  78.       {
  79.          return undefined;
  80.       }
  81.       var _loc2_ = mc.getBounds(_root);
  82.       _loc2_["#289"] = (_loc2_.xMin + _loc2_.xMax) / 2;
  83.       _loc2_["#290"] = (_loc2_.yMin + _loc2_.yMax) / 2;
  84.       var _loc3_ = Bounds["#119"](_loc2_["#289"],_loc2_.yMin);
  85.       if(_loc2_.yMin < _loc3_)
  86.       {
  87.          mc._y += _loc3_ - _loc2_.yMin;
  88.       }
  89.       _loc3_ = Bounds["#119"](_loc2_["#289"],_loc2_.yMax);
  90.       if(_loc2_.yMax > _loc3_)
  91.       {
  92.          mc._y += _loc3_ - _loc2_.yMax;
  93.       }
  94.       _loc3_ = Bounds["#118"](_loc2_.xMin,_loc2_["#290"]);
  95.       if(_loc2_.xMin < _loc3_)
  96.       {
  97.          mc._x += _loc3_ - _loc2_.xMin;
  98.       }
  99.       _loc3_ = Bounds["#118"](_loc2_.xMax,_loc2_["#290"]);
  100.       if(_loc2_.xMax > _loc3_)
  101.       {
  102.          mc._x += _loc3_ - _loc2_.xMax;
  103.       }
  104.    }
  105.    static function ┬º#118┬º(x, y)
  106.    {
  107.       var _loc6_ = Bounds.getYMin();
  108.       if(y < _loc6_)
  109.       {
  110.          y = _loc6_ + 1;
  111.       }
  112.       var _loc5_ = Bounds.getYMax();
  113.       if(y > _loc5_)
  114.       {
  115.          y = _loc5_ - 1;
  116.       }
  117.       var _loc3_ = _root.background._width / 2;
  118.       while(!_root.bounds.hitTest(x,y,true))
  119.       {
  120.          if(x > _loc3_)
  121.          {
  122.             x -= Bounds["#29"];
  123.             if(x <= _loc3_)
  124.             {
  125.                return undefined;
  126.             }
  127.          }
  128.          else
  129.          {
  130.             x += Bounds["#29"];
  131.             if(x >= _loc3_)
  132.             {
  133.                return undefined;
  134.             }
  135.          }
  136.       }
  137.       return x;
  138.    }
  139.    static function ┬º#119┬º(x, y)
  140.    {
  141.       var _loc6_ = Bounds.getXMin();
  142.       if(x < _loc6_)
  143.       {
  144.          x = _loc6_ + 1;
  145.       }
  146.       var _loc5_ = Bounds.getXMax();
  147.       if(x > _loc5_)
  148.       {
  149.          x = _loc5_ - 1;
  150.       }
  151.       var _loc3_ = _root.background._height * 0.8;
  152.       while(!_root.bounds.hitTest(x,y,true))
  153.       {
  154.          if(y > _loc3_)
  155.          {
  156.             y -= Bounds["#29"];
  157.             if(y <= _loc3_)
  158.             {
  159.                return undefined;
  160.             }
  161.          }
  162.          else
  163.          {
  164.             y += Bounds["#29"];
  165.             if(y >= _loc3_)
  166.             {
  167.                return undefined;
  168.             }
  169.          }
  170.       }
  171.       return y;
  172.    }
  173. }
  174.